﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Fast.Framework.Models;


namespace Fast.Framework.Extensions
{

    /// <summary>
    /// Sql函数扩展类
    /// </summary>
    public static class SqlFuncExtensionscs
    {
        #region 聚合函数
        /// <summary>
        /// 取最大值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">源</param>
        public static T Max<T>(this T source)
        {
            return source;
        }

        /// <summary>
        /// 取最小值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">源</param>
        public static T Min<T>(this T source)
        {
            return source;
        }

        /// <summary>
        /// 合计
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">源</param>
        public static T Sum<T>(this T source)
        {
            return source;
        }

        /// <summary>
        /// 平均
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">源</param>
        /// <returns></returns>
        public static T Avg<T>(this T source)
        {
            return source;
        }

        /// <summary>
        /// 计数
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">源</param>
        /// <returns></returns>
        public static int Count<T>(this T source)
        {
            return 0;
        }
        #endregion

        #region 日期和时间函数

        /// <summary>
        /// 年
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public static int Year<T>(this T source)
        {
            return DateTime.Now.Year;
        }

        /// <summary>
        /// 月
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public static int Month<T>(this T source)
        {
            return DateTime.Now.Month;
        }

        /// <summary>
        /// 天数
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source"></param>
        /// <returns></returns>
        public static int Day<T>(this T source)
        {
            return DateTime.Now.Day;
        }

        #endregion

        #region 数学函数

        /// <summary>
        /// 绝对值
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">源</param>
        /// <returns></returns>
        public static T Abs<T>(this T source)
        {
            return source;
        }

        /// <summary>
        /// 四舍五入
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">源</param>
        /// <param name="lenght">长度</param>
        /// <returns></returns>
        public static T Round<T>(this T source, int lenght)
        {
            return source;
        }


        #endregion

        #region 字符串函数
        /// <summary>
        /// 长度
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">源</param>
        /// <returns></returns>
        public static int Len<T>(this T source)
        {
            return source.ToString().Length;
        }
        #endregion

        #region 其它函数
        /// <summary>
        /// 是空
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="source">源</param>
        /// <param name="defaultValue">默认值</param>
        /// <returns></returns>
        public static T IsNull<T>(this T source, T defaultValue)
        {
            return source;
        }
        #endregion
    }
}
